<template>
  <div class="question-home">
    <div class="main-container">
      <div
        class="circle-area circle-practice"
        :style="{ backgroundColor: contentData.practiceCircleButton.bgColor || '#5BAAFF' }"
      >
        <div class="title">{{ contentData.practiceCircleButton.title }}</div>
        <div class="sub-title">{{ contentData.practiceCircleButton.subTitle }}</div>
        <div class="action-button color-practice">{{
          contentData.practiceCircleButton.buttonText
        }}</div>
      </div>

      <div class="right-area">
        <div class="title-area">
          <div class="main-title" :style="titleStyle">{{ contentData.practiceHeader.title }}</div>
          <div class="sub-title" :style="subTitleStyle">{{
            contentData.practiceHeader.subTitle
          }}</div>
        </div>

        <div class="icon-list">
          <div
            class="icon-item"
            v-for="(item, index) in contentData.practice_question_list"
            :key="index"
          >
            <img :src="item.img" alt="" class="icon-img" :style="imgStyle" />
            <div class="icon-label">{{ item.name }}</div>
          </div>
        </div>
      </div>
    </div>

    <div class="main-container">
      <div
        class="circle-area circle-exam"
        :style="{ backgroundColor: contentData.examCircleButton.bgColor || '#5BAAFF' }"
      >
        <div class="title">{{ contentData.examCircleButton.title }}</div>
        <div class="sub-title">{{ contentData.examCircleButton.subTitle }}</div>
        <div class="action-button color-exam">{{ contentData.examCircleButton.buttonText }}</div>
      </div>

      <div class="right-area">
        <div class="title-area">
          <div class="main-title" :style="titleStyle">{{ contentData.examHeader.title }}</div>
          <div class="sub-title" :style="subTitleStyle">{{ contentData.examHeader.subTitle }}</div>
        </div>

        <div class="icon-list">
          <div
            class="icon-item"
            v-for="(item, index) in contentData.exam_question_list"
            :key="index"
          >
            <img :src="item.img" alt="" class="icon-img" :style="imgStyle" />
            <div class="icon-label">{{ item.name }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  const props = defineProps<{
    contentData: any
  }>()

  const titleStyle = computed(() => {
    const s = props.contentData.headerStyle.titleStyle
    return {
      fontSize: s.fontSize + 'px',
      color: s.color,
      fontWeight: s.fontWeight
    }
  })

  const subTitleStyle = computed(() => {
    const s = props.contentData.headerStyle.subTitleStyle
    return {
      fontSize: s.fontSize + 'px',
      color: s.color,
      fontWeight: s.fontWeight
    }
  })

  const imgStyle = computed(() => {
    const s = props.contentData.imgStyle
    return {
      borderRadius: s.borderRadius + 'px'
    }
  })
</script>

<style scoped lang="scss">
  .question-home {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background-color: #fff;
    padding: 70px 0;
  }

  .main-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 40px;
    padding: 0 100px;

    &:first-child {
      margin-bottom: 50px;
    }

    .circle-area {
      min-width: 300px;
      min-height: 300px;
      border-radius: 50%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: #fff;
      text-align: center;
      position: relative;
      cursor: pointer;
      transition: all 0.3s ease;

      &:hover {
        transform: translateY(-10px);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        cursor: pointer;
      }

      .title {
        font-size: 40px;
        font-weight: bold;
      }

      .sub-title {
        margin-top: 6px;
        font-size: 20px;
        opacity: 0.9;
      }

      .action-button {
        font-size: 24px;
        font-weight: 500;
        padding: 8px 30px;
        border-radius: 20px;
        margin-top: 8px;
        display: flex;
        flex-direction: column;
        gap: 12px;
      }

      .color-practice {
        color: #46a1e6;
        background: linear-gradient(to bottom, #f2f9ff, rgba(242, 249, 255, 0.6705882353));
      }

      .color-exam {
        color: #33ce6e;
        background: linear-gradient(to bottom, #f2f9ff, rgba(242, 249, 255, 0.6705882353));
      }
    }

    .circle-practice {
      border: 24px solid #ecf7ff;
    }

    .circle-exam {
      border: 24px solid #eefbf0;
    }

    .right-area {
      flex: 1;
      padding: 0 60px;

      .title-area {
        text-align: center;
        margin-bottom: 30px;

        .main-title {
          font-size: 20px;
          font-weight: bold;
        }

        .sub-title {
          margin-top: 20px;
          font-size: 14px;
          color: #999;
        }
      }

      .icon-list {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        //gap: 20px;

        .icon-item {
          display: flex;
          flex-direction: column;
          align-items: center;
          cursor: pointer;
          box-sizing: border-box;

          transition: all 0.3s ease;
          border-radius: 14px;
          padding: 20px;

          &:hover {
            transform: translateY(-10px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
            cursor: pointer;
          }

          .icon-img {
            width: 120px;
            height: 120px;
            margin-bottom: 16px;
          }

          .icon-label {
            font-size: 28px;
            text-align: center;
            color: black;
          }
        }
      }
    }
  }
</style>
